 #ifndef QQMUSIC_H
#define QQMUSIC_H
#include "commonpage.h"
#include "volumetool.h"
#include"musiclist.h"
#include "musicslider.h"
#include <QWidget>
#include <QJsonArray>  // 需要包含 QJsonArray 的头文件
#include <QMediaPlayer>
#include <QMediaPlaylist>

QT_BEGIN_NAMESPACE
namespace Ui { class QQMusic; }
QT_END_NAMESPACE

class QQMusic : public QWidget
{
    Q_OBJECT

public:
    QQMusic(QWidget *parent = nullptr);
    void initUI();
    void SetShadow();
    void connectSignalAndSlot();
    void onUpdateLikeMusic(bool isLike, QString musicId);
    void initPlayer();
    void onPlayAll(PageType pageType);
    void playAllOfCommonPage(CommonPage* commonPage, int index);
    QJsonArray randomPiction();
    void playMusicByIndex_(CommonPage* page, int index);
    void onCurrentIndexChanged(int index);
    void setMusicSilence(bool isMuted);
    void onDurationChanged(qint64 duration); 
    void onPositionChanged(qint64 duration);
    void onMusicSliderChanged(float value);
    


    ~QQMusic();

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void setPlayerVolume(int vomume);


private slots:
    void on_quit_clicked();
    void onBtFormClick(int id);

    void on_min_clicked();

    void on_volumn_clicked();

    void on_addLocal_clicked();
    void onPlayStateChanged();
    void onPlayMusic();

    void onPlayUpCliked();
    void onPlayDownCliked();
    void onPlaybackModeCliked();
    void onPlaybackModeChanged(QMediaPlaylist::PlaybackMode playbackMode);


private:
    Ui::QQMusic *ui;
    QPoint dragPosition;
    MusicList musicList;
    VolumeTool* volumeTool;
    QMediaPlayer* player;
    QMediaPlaylist* playList;
    CommonPage* curPage;
};
#endif // QQMUSIC_H
